home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / compuserve-file-archive / 05 Programming / CDT128.ARC / CDT.C < prev    next >
Text File  |  2019-04-13  |  7KB  |  212 lines

  1.  
  2. /*****************************************************************************/
  3. /*                                                                           */
  4. /*                      C POWER  DEBUGGING  TOOL                             */
  5. /*                                                                           */
  6. /*                                 CDT                                       */
  7. /*                                                                           */
  8. /*****************************************************************************/
  9.  
  10. /***********************************************************************/
  11. /***********************************************************************/
  12. /*                                                                     */
  13. /* ╘HIS PROGRAM IS COPYRIGHT 1986 BY ┴LAN ┘ORINKS.  ╔T MAY BE FREELY   */
  14. /* DISTRIBUTED FOR NON COMMERCIAL USAGE IF THIS COPYRIGHT NOTICE IS    */
  15. /* LEFT INTACT. ├OMMERCIAL USAGE OF THIS PROGRAM IS EXPLICITLY         */
  16. /* FORBIDDEN WITHOUT THE WRITTEN PERMISSION OF THE AUTHOR.             */
  17. /*                                                                     */
  18. /***********************************************************************/
  19. /***********************************************************************/
  20.  
  21.  
  22. /*     CDT VERSION 1.0    PART 2 OF 15   ╩ULY 25, 1986                 */
  23.  
  24.  
  25. /* USAGE: -P                        PAGE CONTROL OFF.                        */
  26. /*        -R XXXX YY                READ BYTE AT ADDRESS XXXX IN BANK YY.    */
  27. /*        -W XXXX YY ZZ             WRITE BYTE YY AT ADDRESS XXXX IN BANK ZZ.*/
  28. /*        -B VVVV... XXXX YYYY ZZ   FIND NUMERICAL BYTE STRING,VVVV          */
  29. /*                                  IN ADDRESS XXXX THROUGH YYYY IN          */
  30. /*                                  BANK ZZ.                                 */
  31. /*        -C "ABC..." XXXX YYYY ZZ  FIND ALPHA STRING, ABC..., IN ADDRESS    */
  32. /*                                  XXXX THROUGH YYYY IN BANK ZZ.            */
  33. /*        -M XXXX YYYY ZZ           DUMP MEMORY FROM ADDRESS XXXX THROUGH    */
  34. /*                                  YYYY IN BANK ZZ                          */
  35. /*        -D XXXX YYYY ZZ           DISASSEMBLE MEMORY FROM ADDRESS XXXX     */
  36. /*                                  THROUGH YYYY IN BANK ZZ                  */
  37.  
  38. /* ╙╨┼├╔┴╠ ╬╧╘┼: ALL NUMERICAL VALUES ARE TO BE INPUT IN ╚┼╪ !!!!            */
  39.  
  40. #INCLUDE <STDIO.H>
  41. #INCLUDE "DBUG.H"
  42.  
  43.  
  44. /*************************** GLOBAL STORAGE ****************************/
  45.  
  46. INT LNCNT ;     /* COUNT OF LINES SENT TO OUTPUT DEVICE */
  47. INT PAGE ;      /* PAGE FLAG - ╘╥╒┼/╞┴╠╙┼ */
  48.  
  49.  
  50.  
  51. MAIN( ARGC, ARGV )
  52.     INT          ARGC ;
  53.     CHAR        *ARGV[] ;
  54.  
  55.     AUTO   CHAR C ;         /* COMMAND CHARACTER */
  56.     AUTO   INT  COUNT ;     /* ARGUMENT COUNT REGISTER */
  57.     AUTO   INT  (*GO)() ;   /* EXECUTABLE FUNCTION POINTER */
  58.     EXTERN INT  PRñUSAGE(), GETARGS() ;
  59.     EXTERN VOID DASMBL(), DUMP(), FIND(), READ(), WRITE(),
  60.                 NULLñFUNC(), BYTEñSTRNG() ;
  61.  
  62.     IF( ARGC < ═╔╬┴╥╟ )     /* TEST IF THERE ARE ANY ARGUMENTS PASSED */
  63.     █
  64.         PRñUSAGE(1) ;       /* ERROR - NO PARAMETERS */
  65.         ABORT() ;
  66.     ▌
  67.  
  68.  
  69.     /* COUNT WILL BE MAINTAINED BY EACH COMMAND PROCESS */
  70.  
  71.     FOR( COUNT = 1, PAGE = ╘╥╒┼, LNCNT = 0, GO = NULLñFUNC ; COUNT < ARGC ; )
  72.     █
  73.         IF( ARGV[COUNT][0] != '-' )    /* PARAMETER MUST START WITH DASH */
  74.         █
  75.             PRñUSAGE(2) ;
  76.             ABORT() ;
  77.         ▌
  78.  
  79.  
  80.         SWITCH( C = ARGV[COUNT][1] )         /* GET PARAMETER CHARACTER */
  81.         █
  82.             CASE 'P':
  83.                 COUNT++ ;
  84.                 PAGE = ╞┴╠╙┼ ;
  85.                 BREAK ;
  86.  
  87.             CASE 'D':
  88.                 TESTCMD( GO ) ;
  89.                 COUNT++ ;
  90.  
  91.                 /* TEST IF THERE ARE ENOUGH ARGUMENTS FOR COMMAND */
  92.  
  93.                 IF ( (ARGC - COUNT) < 3)
  94.                 █
  95.                     PRñUSAGE(8) ;
  96.                     ABORT() ;
  97.                 ▌
  98.                 IF( GETARGS( ARGV, &COUNT, ─┴╙═┬╠ ) == ┴╥╟┼╥╥ )
  99.                 █
  100.                     PRñUSAGE(4) ;
  101.                     ABORT() ;
  102.                 ▌
  103.                 GO = DASMBL ;
  104.                 BREAK ;
  105.  
  106.             CASE 'M':
  107.                 TESTCMD( GO ) ;
  108.                 COUNT++ ;
  109.                 IF ( (ARGC - COUNT) < 3)
  110.                 █
  111.                     PRñUSAGE(8) ;
  112.                     ABORT() ;
  113.                 ▌
  114.                 IF( GETARGS( ARGV, &COUNT, ─╒═╨ ) == ┴╥╟┼╥╥ )
  115.                 █
  116.                     PRñUSAGE(4) ;
  117.                     ABORT() ;
  118.                 ▌
  119.                 GO = DUMP ;
  120.                 BREAK ;
  121.  
  122.             CASE 'R':
  123.                 TESTCMD( GO ) ;
  124.                 COUNT++ ;
  125.                 IF ( (ARGC - COUNT) < 2)
  126.                 █
  127.                     PRñUSAGE(8) ;
  128.                     ABORT() ;
  129.                 ▌
  130.                 IF( GETARGS( ARGV, &COUNT, ╥┼┴─ ) == ┴╥╟┼╥╥ )
  131.                 █
  132.                     PRñUSAGE(4) ;
  133.                     ABORT() ;
  134.                 ▌
  135.                 GO = READ ;
  136.                 BREAK ;
  137.  
  138.             CASE 'W':
  139.                 TESTCMD( GO ) ;
  140.                 COUNT++ ;
  141.                 IF ( (ARGC - COUNT) < 3)
  142.                 █
  143.                     PRñUSAGE(8) ;
  144.                     ABORT() ;
  145.                 ▌
  146.                 IF( GETARGS( ARGV, &COUNT, ╫╥╔╘┼ ) == ┴╥╟┼╥╥ )
  147.                 █
  148.                     PRñUSAGE(4) ;
  149.                     ABORT() ;
  150.                 ▌
  151.                 GO = WRITE ;
  152.                 BREAK ;
  153.             
  154.             CASE 'B':
  155.             CASE 'C':
  156.                 TESTCMD( GO ) ;
  157.                 COUNT++ ;
  158.                 IF ( (ARGC - COUNT) < 4)
  159.                 █
  160.                     PRñUSAGE(8) ;
  161.                     ABORT() ;
  162.                 ▌
  163.                 IF( GETARGS( ARGV, &COUNT, ╞╔╬─ ) == ┴╥╟┼╥╥ )
  164.                 █
  165.                     PRñUSAGE(4) ;
  166.                     ABORT() ;
  167.                 ▌
  168.                 IF( C == 'B' )
  169.                     BYTEñSTRNG() ;
  170.                 GO = FIND ;
  171.                 BREAK ;
  172.  
  173.             DEFAULT :
  174.                 PRñUSAGE(5) ;
  175.                 ABORT() ;
  176.         ▌
  177.     ▌
  178.     
  179.     (*GO)() ;       /* EXECUTE COMMAND */
  180.     PRINTF("\N") ;
  181.  
  182.  
  183. /* A TEST FOR THE FUNCTION POINTER BEING SET TO SOMETHING OTHER THAN */
  184. /* NULLñFUNC, MUST BE PERFORMED FOR EACH CASE SO THAT POSITION       */
  185. /* INDEPENDENCE OF COMMAND ARGUMENTS MAY BE PROVIDED FOR THE         */
  186. /* COMMAND LINE.                                                     */
  187.  
  188. VOID
  189. TESTCMD( FPTR )
  190.     VOID    (*FPTR)() ;
  191.  
  192.     EXTERN VOID NULLñFUNC(), PRñUSAGE(), ABORT() ;
  193.  
  194.     IF( FPTR != &NULLñFUNC )
  195.     █
  196.         PRñUSAGE(3) ;
  197.         ABORT() ;
  198.     ▌
  199.  
  200. VOID
  201. NULLñFUNC()
  202.     EXTERN VOID PRñUSAGE() ;
  203.  
  204.     PRñUSAGE(7) ;
  205.  
  206.